package com.sc.service.impl.patrol;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.domain.patrol.PatrolPath;
import com.sc.dto.PatrolPathDTO;
import com.sc.mapper.patrol.PatrolPathMapper;
import com.sc.result.PageResult;
import com.sc.service.patrol.PatrolPathService;
import com.sc.vo.PatrolPathVO;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PatrolPathServiceImpl extends ServiceImpl<PatrolPathMapper, PatrolPath> implements PatrolPathService {

    @Override
    public PageResult<PatrolPathVO> pageQuery(PatrolPathDTO patrolPathDTO) {
        int start = (patrolPathDTO.getPageNum() - 1) * patrolPathDTO.getPageSize();
        int end = patrolPathDTO.getPageNum() * patrolPathDTO.getPageSize();

        List<PatrolPathVO> list = baseMapper.pageQuery(patrolPathDTO);
        PageResult<PatrolPathVO> page = new PageResult<>(list.size(), list.subList(start, Math.min(list.size(), end)));
        return page;
    }
}
